package com.dong.rabbitmq.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;


/**
 * @author dongjian
 */
public class RabbitMqUtil {

    /**
     * 创建连接信道
     * @return
     * @throws Exception
     */
    public static Channel getChannel() throws Exception{
        // 创建工厂
        ConnectionFactory cf = new ConnectionFactory();
        //工厂设置
        cf.setHost("192.168.1.104");
        cf.setUsername("guest");
        cf.setPassword("guest");
        // 用户对应的v-host
        cf.setVirtualHost("/dong");
        // 创建连接
        Connection connection = cf.newConnection();
        // 获取信道
        Channel channel = connection.createChannel();
        return channel;
    }
}
